#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

struct ListNode {
    int val;
    struct ListNode* next;
};
typedef struct ListNode ListNode;

struct ListNode* reverseList(struct ListNode* head) {
    ListNode* newhead = NULL;
    ListNode* pcur = head;
    while (pcur->next)
    {
        if (newhead == NULL)
        {
            newhead = pcur;
        }
        else
        {
            pcur->next = newhead;
            newhead = pcur;
        }
        pcur = pcur->next;
    }
    return newhead;
}

void test1()
{
    ListNode* node1 = (ListNode*)malloc(sizeof(ListNode));
    ListNode* node2 = (ListNode*)malloc(sizeof(ListNode));
    ListNode* node3 = (ListNode*)malloc(sizeof(ListNode));
    ListNode* node4 = (ListNode*)malloc(sizeof(ListNode));
    ListNode* node5 = (ListNode*)malloc(sizeof(ListNode));

    node1->val = 1;
    node2->val = 2;
    node3->val = 3;
    node4->val = 4;
    node5->val = 5;

    node1->next = node2;
    node2->next = node3;
    node3->next = node4;
    node4->next = node5;
    node4->next = NULL;

    ListNode* plist = node1;
    reverseList(plist);
}
int main()
{
    test1();
    return 0;
}
